import request from '@/utils/request'

export function userSearch(name) {
  return request({
    url: '/api/admin/reference/user',
    method: 'get',
    params: { name }
  })
}

export function addReference(obj) {
  return request({
    url: '/api/admin/article',
    method: 'post',
    data: obj
  })
}

export function fetchArticle(id) {
  return request({
    url: '/api/admin/article/' + id,
    method: 'get',
    params: { id }
  })
}

export function fetchList(query) {
  return request({
    url: 'api/admin/article/page',
    method: 'get',
    params: query
  })
}

export function getCategory(query) {
  return request({
    url: 'api/admin/category/page',
    method: 'get',
    params: query
  })
}
export function allCategory() {
  return request({
    url: 'api/admin/category/all',
    method: 'get'
  })
}

export function addCategory(obj) {
  return request({
    url: 'api/admin/category',
    method: 'post',
    data: obj
  })
}

export function updateCategory(obj, id) {
  return request({
    url: 'api/admin/category/' + id,
    method: 'put',
    data: obj
  })
}

export function deleteCategory(id) {
  return request({
    url: 'api/admin/category/' + id,
    method: 'delete'
  })
}


export function editArticle(id, obj) {
  return request({
    url: 'api/admin/article/' + id,
    method: 'put',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: 'api/admin/category/' + id,
    method: 'get'

  })
}

export function deleteArticle(id) {
  return request({
    url: 'api/admin/article/' + id,
    method: 'delete'
  })
}

